public without sharing class AttachmentWorkOrderHandler {
	////将工单的非签字的附件上传时间统计到 工单的完成时间
    public static void getUploadTime(List<Attachment> attList){
    	Map<Id,Attachment> workIds = new Map<Id,Attachment> ();
    	///保存工单的ID
    	for (Attachment att :attList ) {
    		///如果是工单 并且 附件名称中不包含 "sign" 取最新的附件上传时间
    		if (att.ParentId.getSobjectType() == WorkOrder__c.SobjectType && att.Name != null && !att.Name.contains('Sign')) {
    			
    			if (workIds.containsKey(att.ParentId)) {
    				Attachment oldAtt = workIds.get(att.ParentId);
    				if(oldAtt.CreatedDate > att.CreatedDate)continue;
    			}
    			workIds.put(att.ParentId,att);
    		}
    	}
    	List<WorkOrder__c>  woList= new List<WorkOrder__c>();
    	///排除 保养工单  服务工单   代理安装工单  非代理安装工单
    	for (WorkOrder__c wo : [select Id ,AccessoryUploadTime__c from WorkOrder__c where Id in:workIds.keySet() 
    		and RecordType.DeveloperName != 'MaintenanceOrder' and RecordType.DeveloperName != 'ServiceOrder' 
    		and RecordType.DeveloperName != 'NonAgentInstallationOrder' and RecordType.DeveloperName != 'InstallationOrder'  ]) {
    		
    		if (workIds.containsKey(wo.Id)) {
    			Attachment att = workIds.get(wo.Id);
    			wo.AccessoryUploadTime__c = att.CreatedDate;
    			woList.add(wo);
    		}
    	}
    	if (woList.size() > 0) update woList;
    }
}